import React from 'react';
import dynamic from 'dva/dynamic';
import { Route } from 'dva/router';
import { isToken } from '../utils/judgmentEquipment.js'

export default function orderListRoute(app) {
    const Login = dynamic({
      app,
      models: () => {
        return [
          import(/* webpackChunkName: "loginModel" */'../models/login/loginModel'),
        ];
      },
      component: () => import(/* webpackChunkName: "login" */'../routes/login/login'),
    });


    const OrderList = dynamic({
        app,
        models: () => {
            return [
                import(/* webpackChunkName: "orderListModel" */'../models/orderList/orderListModel'),
            ];
        },
        component:()=>import(/* webpackChunkName: "orderList" */'../routes/orderList/orderList'),
    });

    const OrderDetail = dynamic({
        app,
        models: ()=>{
            return [
                import(/* webpackChunkName: "orderListModel" */'../models/orderList/orderListModel')
            ];
        },
        component:()=>import(/* webpackChunkName: "orderDetail" */'../routes/orderList/orderDetail')
    });

    const EvaluateAndAfter = dynamic({
        app,
        models: ()=>{
            return [
                import(/* webpackChunkName: "orderListModel" */'../models/orderList/orderListModel')
            ];
        },
        component:()=>import(/* webpackChunkName: "evaluateList" */'../routes/orderList/evaluateAndAfter')
    });
    const PayMent = dynamic({
        app,
        models: ()=>{
            return [
                import(/* webpackChunkName: "orderListModel" */'../models/orderList/orderListModel')
            ];
        },
        component:()=>import(/* webpackChunkName: "payMent" */'../routes/orderList/payMent')
    });
    const PaySuccess = dynamic({
        app,
        models: ()=>{
            return [
                import(/* webpackChunkName: "orderListModel" */'../models/orderList/orderListModel')
            ];
        },
        component:()=>import(/* webpackChunkName: "paySuccess" */'../routes/orderList/paySuccess')
    });
    const Evaluate = dynamic({
        app,
        models: ()=>{
            return [
                import(/* webpackChunkName: "orderListModel" */'../models/orderList/orderListModel'),
                import(/* webpackChunkName: "evaluateListModel" */'../models/evaluate/evaluateDetailModel'),
            ];
        },
        component:()=>import(/* webpackChunkName: "evaluate" */'../routes/orderList/evaluate')
    });
    const AfterSale = dynamic({
        app,
        models: ()=>{
            return [
                import(/* webpackChunkName: "orderListModel" */'../models/orderList/orderListModel')
            ];
        },
        // component:()=>import(/* webpackChunkName: "afterSale" */'../routes/orderList/afterSale')
        component:()=>import(/* webpackChunkName: "afterSale" */'../routes/orderList/newAfterSale')
    });
    const ApplyAfterSale = dynamic({
        app,
        models: ()=>{
            return [
                import(/* webpackChunkName: "orderListModel" */'../models/orderList/orderListModel'),

            ];
        },
        component:()=>import(/* webpackChunkName: "applyAfterSale" */'../routes/orderList/applyAfterSale')
    });


    const ShowCode = dynamic({
        app,
        models: () => {
            return [
                import(/* webpackChunkName: "payTypeModel" */'../models/orderList/orderListModel'),
            ];
        },
        component: () => import(/* webpackChunkName: "orderpaytype" */'../routes/orderList/showCode'),
    });
    const FilterOrder = dynamic({
        app,
        models: () => {
            return [
                import(/* webpackChunkName: "payTypeModel" */'../models/orderList/orderListModel'),
            ];
        },
        component: () => import(/* webpackChunkName: "orderpaytype" */'../routes/orderList/filterOrder'),
    });

    const PayFail = dynamic({
        app,
        models: ()=>{
            return [
                import(/* webpackChunkName: "orderListModel" */'../models/orderList/orderListModel')
            ];
        },
        component:()=>import(/* webpackChunkName: "paySuccess" */'../routes/orderList/payFail')
    });

    const ReturnDetail = dynamic({
        app,
        models: ()=>{
            return [
                import(/* webpackChunkName: "orderListModel" */'../models/orderList/orderListModel')
            ];
        },
        component:()=>import(/* webpackChunkName: "afterSale" */'../routes/orderList/returnDetail')
    });

    const SearchOrder = dynamic({
        app,
        models: ()=>{
            return [
                import(/* webpackChunkName: "orderListModel" */'../models/stores/storesShowModel')
            ];
        },
        component:()=>import(/* webpackChunkName: "paySuccess" */'../routes/orderList/SearchOrder')
    });

    const ReturnSuccess = dynamic({
        app,
        models: ()=>{
            return [
                import(/* webpackChunkName: "orderListModel" */'../models/stores/storesShowModel')
            ];
        },
        component:()=>import(/* webpackChunkName: "paySuccess" */'../routes/orderList/returnSuccess')
    });

    const OrderCancel = dynamic({
        app,
        models: () => {
            return [
                import(/* webpackChunkName: "orderCancelModel" */'../models/orderList/orderListModel'),
            ];
        },
        component: () => import(/* webpackChunkName: "orderCancel" */'../routes/order/orderCancel'),
    });

    return (
        [
            <Route key="/orderList" exact path="/orderList/:data" children={(props) => isToken() ? <OrderList {...props}/>  : <Login {...props} /> }/>,
            <Route key="/afterSale" exact path="/afterSale" children={(props) => isToken() ? <AfterSale {...props}/>  : <Login {...props} /> }/>,
            <Route key="/afterSale" exact path="/applyAfterSale/:data/:Data" component={ApplyAfterSale}/>,
            <Route key="/payMent" exact path="/payMent/:data/:orderId?" component={PayMent}/>,
            <Route key="/evaluateAndAfter" exact path="/EvaluateAndAfter/:data/:idx" component={EvaluateAndAfter}/>,
            <Route key="/evaluate" exact path="/evaluate/:data/:Data/:id" component={Evaluate}/>,
            <Route key="/paySuccess" exact path="/paySuccess/:data" component={PaySuccess}/>,
            <Route key="/orderDetail" exact path="/orderDetail/:data" component={OrderDetail}/>,
            <Route key="/orderCancel" exact strict path="/orderCancel/:data" component={OrderCancel}/>,
            <Route key="/showCode" exact path="/showCode" component={ShowCode}/>,
            <Route key="/filterOrder" exact path="/filterOrder/:data" component={FilterOrder}/>,
            <Route key="/payFail" exact path="/payFail" component={PayFail}/>,
            <Route key="/searchOrder" exact path="/searchOrder/:data" component={SearchOrder}/>,
            <Route key="/returnDetail" exact path="/returnDetail/:id" component={ReturnDetail}/>,
            <Route key="/returnSuccess" exact path="/returnSuccess/:data" component={ReturnSuccess}/>,
        ]
    );
}
